package Model;

import Model.Cages.Cage;
import Model.Animals.*;
import Model.Staff;

/**
 *
 * @author HOANG TRUONG DINH
 */
public class Player {

    String name;
    double balance;
    Zoo zoo;

    public Player() {
        name = "Guest";
        balance = 100000;
        zoo = new Zoo();
    }

    public Player(String name, double balance) {
        this.name = name;
        this.balance = balance;
        zoo = new Zoo();
    }

    public double getBalance() {
        return balance;
    }

    public String getName() {
        return name;
    }

    public double purchaseRoad() {
        return 0;
    }

    public double purchaseFence() {
        return 0;
    }

    public boolean purchaseCase(Cage c) {
        if (c.calCost() > this.balance) {
            return false;
        } else {
            zoo.addCase(c);
            balance -= c.calCost();
        }
        return true;
    }

    public boolean purchaseAnimal(Cage c, Animal a) {
        if (a.calCost() > this.balance) {
            return false;
        } else {
            if (zoo.addAnimalToCase(c, a)) {
                balance -= a.calCost();
                return true;
            } else {
                return false;
            }
        }
    }

    public boolean hireStaff(Staff f) {
//        if (f.calCost() > this.balance) {
//            return false;
//        } else {
//            zoo.addStaff(f);
//            balance -= f.calCost();
//        }
        return true;
    }

    public boolean removeAnimal(Cage c, Animal a) {
        return zoo.removeAnimalFromCase(c, a);
    }

    public void removeStaff(Staff f) {
        zoo.removeStaff(f);
    }

    public void removeCase(Cage c) {
        zoo.removeCase(c);
    }

    public boolean upgradeCase(Cage c) {
        if (c.upgradeCost() > this.balance) {
            return false;
        } else {
            balance -= c.upgradeCost();
            zoo.upgradeCase(c);
        }
        return true;
    }

    public boolean upgradeAnimal(Cage c, Animal a) {
        if (a.upgradeCost() > this.balance) {
            return false;
        } else {
            balance -= a.upgradeCost();
            zoo.upgradeAnimal(c, a);
        }
        return true;
    }

    public boolean upgradeStaff(Staff f) {
//        if (f.upgradeCost() > this.balance) {
//            return false;
//        } else {
//            balance -= f.upgradeCost();
//            zoo.upgradeStaff(f);
//        }
        return true;
    }

    public boolean feedAnimal(Animal a) {
        return true;
    }

    public boolean payStaffSalary(Staff f) {
        return true;
    }
}
